package chapter3.test09;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class Calulator {

		public Integer calcSum(String filepath) throws IOException{
			BufferedReader br = null;
			Integer sum = 0;
			try{
					br = new BufferedReader(new FileReader(filepath));
					
					String line = null;
					while((line = br.readLine()) != null){
							sum += Integer.valueOf(line);
					}
					
			}catch(IOException e){
				System.out.println(e.getMessage());
			}finally{
				if(br !=null){
					try{br.close();}catch(IOException e){System.out.println(e.getMessage());}
				}
				br.close();
			}
			return sum;
			
		}
}
